"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
exports.__esModule = true;
var axios_1 = require("axios");
/**
 * 装饰器-柯里化（因为装饰器只会接收后面函数的一些参数进行操作)
 * @装饰器名 = @自定义函数(参数)，随后在自定义函数中返回装饰器函数
 * 所以我们先用Get()接收url，在装饰器内部就能使用url参数，最终返回装饰器函数就行了
 */
var Get = function (url) {
    //返回装饰器函数
    return function (target, key, descriptor) {
        var fnc = descriptor.value; //getList()函数
        axios_1["default"].get(url).then(function (res) {
            fnc(res, { status: 200, success: true });
        })["catch"](function (e) {
            fnc(e, { status: 500, success: false });
        });
    };
};
var Controller = /** @class */ (function () {
    function Controller() {
    }
    //@用来接收装饰器(方法)
    Controller.prototype.getList = function (res, status) {
        console.log(res, status);
    };
    __decorate([
        Get('http://jsonplaceholder.typicode.com/posts')
    ], Controller.prototype, "getList");
    return Controller;
}());
